<?php

require_once 'TestFailure.php';

class tView_TestCase {
	
	protected $_name;
	protected $_class;
	protected $_file;
	protected $_line;
	protected $_assertions;
	protected $_time;
	
	protected $_failure = null;
	
	public function __construct($testCase) {		
		$this->_name = (string)$testCase['name'];
		$this->_class = (string)$testCase['class'];
		$this->_file = (string)$testCase['file'];
		$this->_line = (int)$testCase['line'];
		$this->_assertions = (int)$testCase['assertions'];
		$this->_time = (float)$testCase['time'];
		
		if (isset($testCase->{'failure'})) {
			$this->_failure = new tView_TestFailure($testCase->{'failure'});
		}
	}
	
	public function getTime() {
		return $this->_time;
	}
	
	public function getType() {
		if (!is_null($this->_failure)) {
			return tView_TestSuite::TYPE_FAILED;
		}
		return tView_TestSuite::TYPE_PASSED;
	}
	
	public function getName() {
		return $this->_name;
	}
	
	public function getFailure() {
		return $this->_failure;
	}
	
}
